package com.hxkj.dao;


import com.hxkj.domain.po.AuthFunction;
import com.hxkj.domain.po.AuthRole;
import com.hxkj.domain.po.AuthUser;
import com.hxkj.domain.po.Site;

import java.util.List;
import java.util.Set;

/**
 * 用户mapper
 * <p>
 * Created by chenwei on 2018/5/15.
 */
public interface UserDao {


    /**
     * 根据账号获取用户
     * @param account
     * @return
     * @throws Exception
     */
    AuthUser findByAccount(String account) throws Exception;


    /**
     * 根据账号获取角色码集合
     * @param account
     * @return
     * @throws Exception
     */
    Set<String> findRolesByAccount(String account) throws Exception;


    /**
     * 根据账号获取功能码集合
     * @param account
     * @return
     * @throws Exception
     */
    Set<String> findPermissionsByAccount(String account) throws Exception;

    /**
     * 根据账号获取角色
     * @param authUser
     * @return
     */
    AuthRole getRoleByAccount(AuthUser authUser);


    /**
     * 根据账号和appKey查找菜单集合
     * @param account
     * @param appKey
     * @return
     */
//    @Cached(name = "user:menu:",key = "args[0]",cacheType = CacheType.REMOTE,expire = 1,timeUnit = TimeUnit.HOURS)
    List<AuthFunction> findFunctions(String account, String appKey,String siteId);

    /**
     * 通过account和appkey获得
     * @param appKey account
     * @return
     */
    List<AuthRole>getRolesByAccount(String appKey, String account);


    /**
     * 通过id获取用户信息
     * @param userId
     * @return
     */
//    @Cached(name = "cms:user:login:",key = "args[0]",cacheType = CacheType.REMOTE,expire = 1,timeUnit = TimeUnit.HOURS)
    AuthUser getUserInfoById(String userId);


    /**
     * 通过账户获取用户站点
     * @param account
     * @return
     * @throws Exception
     */
    List<Site> getUserSiteByAccount(String account) throws Exception;


    /**
     * 通过站点id获取功能
     * @param siteId
     * @return
     */
    List<AuthFunction> findAllFunctionsBySite(Long siteId);


    /**
     * 根据站点获取权限
     * @param siteId
     * @return
     */
    Set<String> findPermissionsBySite(Long siteId);
}
